I'm not sure that I understand exactly what you are trying to do. I'm
guessing (and I mean guessing) that the tables are something like:
ansprechpartner: private owner
kunden: client
agenturen: estate agent
So are you trying to get is get details on all properties both privately
rented and rented via an agency?
I think a \d of all the tables involved would be useful to make sense of it
all.
In the interim though, if you only what unique combinations of ag.name1 and
k.name1 you could try:
SELECT DISTINCT k.name1, ag.name1
FROM ansprechpartner ap, kunden k, agenturen ag
WHERE ap.kunden_nr = k.kunden_nr OR ap.agentur_nr = ag.agentur_nr;
But somethings tells me that's not what you actually wanted!
>Hello,
>
>I'm trying to join three tables, where I need only one piece of data from
>two of the tables. The code I wrote is:
>
>SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, ap.telefon, ap.fax,
>ap.email, ap.kunden_nr, k.name1, ap.agentur_nr, ag.name1
>FROM ansprechpartner ap, kunden k, agenturen ag
>WHERE ap.kunden_nr = k.kunden_nr OR ap.agentur_nr = ag.agentur_nr
>ORDER BY nachname"
>
>The problem is that each row from each table is combined with each row of
>the other tables. I know the code is wrong, but I don't know how to write
>it so that the results show only the actual value of ag.name1 and k.name1,
>and not all of the possible combinations.
>
>Is there a way of limiting how the rows are built up? Pardon for novice
>nature of this question...
>
>Thanks in advance,
>
>Anja
+-------------------------+--------------------------------------+
| Stuart Rison | Ludwig Institute for Cancer Research |
+-------------------------+ 91 Riding House Street |
| Tel. (0171) 878 4041 | London, W1P 8BT, UNITED KINGDOM. |
| Fax. (0171) 878 4040 | stuart@ludwig.ucl.ac.uk |
+-------------------------+--------------------------------------+